package cn.studyjams.s2.sj0110.what2eat;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class Result extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_result);

        ImageView imageView = (ImageView) findViewById(R.id.result_img);
        TextView textView = (TextView) findViewById(R.id.result_name);
        Intent intent = getIntent();
        imageView.setImageResource(intent.getIntExtra("img",R.drawable.buchi));
        textView.setText(intent.getStringExtra("name"));

        Button button = (Button) findViewById(R.id.result_again_btn);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                jumpMain();
            }
        });
    }

    /**
     * 点击返回退出到桌面
     */
    @Override
    public void onBackPressed() {
        this.jumpMain();
    }

    private void jumpMain(){
//        Intent intent_r = new Intent(this,MainActivity.class);
//        startActivity(intent_r);
        finish();
    }

}
